package org.dt.common.sequence.config;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @author: yujiadong
 * @create: 2019/01/09 17:33
 **/
@Setter
@Getter
@ToString
public class SeqHolderSpec {
    /**
     * 初始时缓存中号段的总宽度
     */
    private int   capacity     = 1000;
    /**
     * 缓存剩余号段到指定比例后触发后台补充
     */
    private Float loadFactor   = 0.5f;
    /**
     * 流量时间窗口数量
     */
    private int   statSlotSize = 100;

    /**
     * 每个流量时间窗口对应时间毫秒数
     */
    private long msEachStatSlot = 100;

    /**
     * 最近时间窗口占总窗口数比例
     */
    private float latestSlotRate = 0.3f;

    public static SeqHolderSpec parse(String s) throws IllegalAccessException {
        return ParseUtil.parseSpec(s, new SeqHolderSpec());
    }
}
